<template>
  <div class="app-container">    

    <el-table v-loading="loading" :data="evalResultsList">
      <el-table-column label="学期" align="center" prop="semName" />
      <el-table-column label="量化考核得分" align="center" prop="quantifyScore" />
      <el-table-column label="评价得分" align="center" prop="evaluateScore" />
      <el-table-column label="综合得分" align="center" prop="score" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
          >查看</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 添加或修改考评结果对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px" disabled>
        <el-form-item label="量化分数" prop="quantifyScore">
          <el-input v-model="form.quantifyScore" placeholder="请输入量化分数" />
        </el-form-item>
        <el-form-item label="评价分数" prop="evaluateScore">
          <el-input v-model="form.evaluateScore" placeholder="请输入评价分数" />
        </el-form-item>
        <el-form-item label="综合得分" prop="score">
          <el-input v-model="form.score" placeholder="请输入打分" maxLength="50" show-word-limit />
        </el-form-item>
        <el-form-item label="老师寄语" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"  maxLength="65535" show-word-limit />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { myEvalResults, getEvalResults, delEvalResults, updateEvalResults, exportEvalResults } from "@/api/evaluate/evalResults";
import { selectTeacher} from "@/api/base/teacher";
import { selectSemster} from "@/api/base/semster";

export default {
  name: "MyEvalResults",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 教师数据
      teacherList: [],
      // 评教结果表格数据
      evalResultsList: [],
      // 学期数据
      semsterList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        semId: null,
        teacherId: null,
        score_start: null,
        score_end: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        semId: [
          { required: true, message: "学期不能为空", trigger: "blur" }
        ],
        teacherId: [
          { required: true, message: "教师不能为空", trigger: "blur" }
        ],
        score: [
          { required: true, message: "打分不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getList();
    selectSemster({'status':1}).then(response => {
      this.semsterList = response.rows;
    });
  },
  methods: {
    /** 查询评教结果列表 */
    getList() {
      this.loading = true;
      myEvalResults(this.queryParams).then(response => {
        this.evalResultsList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        semId: null,
        teacherId: null,
        score: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 查看按钮操作 */
    handleView(row) {
      this.form = row;
      this.open = true;
      this.title = "查看考评结果";
    }
  }
};
</script>
